//
//  TestAppDelegate.m
//  YSSmartHome
//
//  Created by yanghao on 2016/10/9.
//  Copyright © 2016年 yahaong. All rights reserved.
//

#import "TestAppDelegate.h"
#import "DeviceEditController.h"
#import "TestViewController.h"
#import "Bugly/Bugly.h"
#import "ZTLCCameraUtil.h"
#import <XAISDK/XAIConvertorHelper.h>
static NSString * const kZTBUGLYAPPID  = @"900030761";

@interface TestAppDelegate ()
<
BuglyDelegate
>

@end
@implementation TestAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//    [self setupBugly];
//    [ZTLCCameraUtil unbundling:@"2D050C8PAK01293"];
    char b[8] = {0};
    uint16_t a = 0x1234;
    memcpy(b, &a, sizeof(a));
    
    uint16_t c =  [XAIConvertorHelper bytesToUnsignedshort:b offset:0];
    NSLog(@"c = %04x",c);
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    TestViewController *editVc= [[TestViewController alloc]init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:editVc];
    self.window.rootViewController = nav;
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)setupBugly {
    BuglyConfig * config = [[BuglyConfig alloc] init];
#if DEBUG
    config.debugMode = YES;
#endif
    config.reportLogLevel = BuglyLogLevelWarn;
    config.blockMonitorEnable = YES;
    config.blockMonitorTimeout = 1.5;
    config.channel = @"Bugly";
    config.delegate = self;
    [Bugly startWithAppId:kZTBUGLYAPPID
#if DEBUG
        developmentDevice:YES
#endif
                   config:config];
    [Bugly setUserIdentifier:[NSString stringWithFormat:@"User: %@", [UIDevice currentDevice].name]];
}


#pragma mark - BuglyDelegate
- (NSString *)attachmentForException:(NSException *)exception {
    NSLog(@"(%@:%d) %s %@",[[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, __PRETTY_FUNCTION__,exception);
    
    return @"This is an attachment";
}


@end
